package com.woniu.adminservice.dao;

import com.woniu.adminservice.dto.MenuDTO;
import com.woniu.adminservice.entity.Menus;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenusDao {
    Menus queryById(Integer id);

    List<Menus> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
    
    List<Menus> findAll();

    List<Menus> queryAll(Menus menus);

    int insert(Menus menus);

    int update(Menus menus);

    void deleteById(Integer id);

    List<String> selectPermsByRoles(List roleId);

    List<Menus> selectMenusByRoles(List roleId);

    @Select("select * from menus where title= #{value}")
    List<Menus> selectMenusByTitle(String title);

    @Select("select * from menus where parent_id= #{id}")
    Menus selectMenuByParentId(Integer id);

    @Select("select * from menus where parent_id= #{parentId} and title = #{title}")
    Menus selectMenusByTitleParentId(String title, Integer parentId);

    @Select("select * from menus left join roles_menus on roles_menus.menu_id=menus.id where role_id=#{value}")
    List<Menus> selectMenusByRoleId(Integer id);
}